#ifndef MFESTPRV_H
#define MFESTPRV_H


#include "packagemanagement.h"
using namespace PackageManagement;

//
// STOP:  If you want to manipulate package manifest files, use the classes
//		  in pkgmfest.h.
//
// None of these classes are to be exposed to the outside or used directly by
// app code.  These classes should only be used directly by the classes in
// pkgmfest.h.
//
// These are PRIVATE classes.
//

#include "pack8.h"

typedef struct _PMHead
{
	enum Constants
	{
		PMH_Id		= 0x4d676b50,		// MgkP (in file: PkgM)
		PMH_Version = 0x00010003L		// 2byte major, 2byte minor
	};

	bool8 load(pCStream);					// (not PMPackages, Filenames)
	bool8 save(pCStream, uint32, uint32);	// (not PMPackages, Filenames)
	bool8 saveFileOfs(pCStream);

	uint32 ID;
	uint32 Version;
	uint32 Size;
	uint32 SizePkg;
	uint32 SizeGame;
	uint32 NumPkgs;
	uint32 NumFilenames;
	uint32 FilenameOfs;
	//
	// PMPackages follow
	// Filenames follow: <len byte><name>...
	//
} PMHead;

typedef struct _PMHeadV12
{
	enum Constants
	{
		PMH_Id		= 0x4d676b50,		// MgkP (in file: PkgM)
		PMH_Version = 0x00010002L		// 2byte major, 2byte minor
	};

	bool8 load(pCStream);					// (not PMPackages, Filenames)
	bool8 save(pCStream, uint32, uint32);	// (not PMPackages, Filenames)
	bool8 saveFileOfs(pCStream);

	uint32 ID;
	uint32 Version;
	uint32 Size;
	uint32 SizePkg;
	uint32 SizeGame;
	uint32 NumPkgs;
	uint32 NumFilenames;
	uint32 FilenameOfs;
	//
	// PMPackages follow
	// Filenames follow: <len byte><name>...
	//
} PMHeadV12;

typedef struct _PMPackageV12
{
	bool8 load(pCStream, const PMHead&, PackageManagement::Package*);
	bool8 save(pCStream File, PackageManagement::Package* p);

	uint8 NameLen;
	uint8 DLLNameLen;
	uint16 NumGames;
	uint32 ZipSize;
	uint32 Version;
	uint32 ReqLobbyVer;
	uint32 Flags;
	uint32 reserved;
	enum SavedFlags
	{
		NONE			= 0x00,
		INSTALLED		= 0x01,
		LOBBY			= 0x02,
		CASCADEMENUS	= 0x04,
		RSYNCNEEDED		= 0x08,
		BANK			= 0x10
	};
//
//	Name follows
//	DLLName follows
//	PMGames follow
//
} PMPackageV12;

typedef struct _PMPackage
{
	bool8 load(pCStream, const PMHead&, PackageManagement::Package*);
	bool8 save(pCStream, PackageManagement::Package*);

	uint8 NameLen;
	uint8 DLLNameLen;
	uint32 ZipSize;
	uint32 Version;
	uint32 Flags;
	uint8 NumDepends;
	uint32 UnZipSize;
	enum SavedFlags	
	{
		NONE			= 0x00,
		INSTALLED		= 0x01,
//		LOBBY			= 0x02,
		RSYNCNEEDED		= 0x08,
	};
//
//	Name follows
//	DLLName follows
//	Dependencies follow
//
} PMPackage;

typedef struct _PMDependency
{
	bool8 load(pCStream, const PMHead&, PkgDependency*);
	bool8 save(pCStream, PkgDependency*);

	uint8  DependencyNameLen;
	uint32 RequiredVersion;
//
//	Dependencie Name follows
} PMDependency;

typedef struct _PMGame
{
	uint8 NameLen;
	uint8 IconNameLen;
	uint16 Dummy;
	uint32 GameInit;
//
//	Name follows
//	IconName follows
//
} PMGame;




#include "packend.h"

#endif
